#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
int main()
{
	int n = 0;
	int m = 0;
	scanf("%d %d", &n, &m);
	int arr[100];
	int arr1[100];
	int i = 0;
	for (i = 0; i < n; i++)
	{
		scanf("%d", &arr[i]);
	}
	for (i = 0; i < m; i++)
	{
		scanf("%d", &arr1[i]);
	}
	i = 0;
	int k = 0;
	while (i<n&&k<m)
	{
		if (arr[i] < arr1[k ])
		{
			printf("%d ", arr[i]);
			i++;
		}
		else
		{
			printf("%d ", arr1[k]);
			k++;
		}
	}
	if (i < n)
	{
		for (; i < n; i++)
		{
			printf("%d ", arr[i]);
		}
	}
	else
	{
		for (; k < m; k++)
		{
			printf("%d ", arr1[k]);
		}
	}
	return 0;
}